package com.xh3140.xwidget.dialog.params;


import android.content.Context;

import androidx.annotation.NonNull;

/**
 * 配置属性抽象类
 */
public abstract class AbstractParams {
  @NonNull
  public final Context context;
  public final float density;

  public AbstractParams(@NonNull Context context) {
    this.context = context;
    this.density = context.getResources().getDisplayMetrics().density;
  }

  public int dp2px(int dp) {
    return (int) (dp * density);
  }

  @NonNull
  public int[] dps2pxs(@NonNull int... dps) {
    final int[] pxs = new int[dps.length];
    for (int i = 0; i < dps.length; ++i) {
      pxs[i] = (int) (dps[i] * density);
    }
    return pxs;
  }
}